package com.ruoyi.wechat.api;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.wechat.domain.CampUser;
import com.ruoyi.wechat.domain.WxLoginUser;
import com.ruoyi.wechat.service.ICampUserService;
import com.ruoyi.wechat.service.IWxLoginService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("wechat")
public class WxLoginController extends BaseController {
    @Autowired
    private IWxLoginService loginService;

    @PostMapping("login")
    public AjaxResult login(String code,String username,String password){
        WxLoginUser login = loginService.login(code, username, password);
        return success(login);
    }

    @Autowired
    private ICampUserService campUserService;
    @PostMapping("/updateUserInfo")
    public AjaxResult updateUserInfo(@RequestBody CampUser campUser){

        return success(campUserService.updateCampUser(campUser));
    }
}
